package com.newcoder.leetcode;

import java.util.Arrays;

public class String_reverse {

    public static void main(String[] args) {
        int result = new String_reverse().reverse(1534236469);
        System.out.println(result);
    }

    public int reverse(int x) {
        StringBuffer sb = new StringBuffer(String.valueOf(x));
        sb.reverse();
        String s = sb.toString();
        if(s.lastIndexOf("-")>0){
            s = s.replace("-","");
            s = "-"+s;
        }
        try {
            return Integer.parseInt(s);
        } catch (NumberFormatException e) {
            return 0;
        }
    }
}
